import { createSlice } from "@reduxjs/toolkit";

const counterSlice = createSlice({
  name: 'counter',
  initialState: {
    count: 99,
    message: '你好啊, 李银河'
  },
  reducers: {
    addNumberAction(state, action) {
      state.count = state.count + action.payload;
    },
    subNumberAction(state, action) {
      state.count = state.count - action.payload;
    },
    changeMessageAction(state, { payload }) {
      state.message = payload
    }
  }
})

export const { addNumberAction, subNumberAction, changeMessageAction} = counterSlice.actions
export default counterSlice.reducer
